﻿using Architecture.API.Application.TraceabilityCommand.SlaughterCommand;
using MediatR;
using Traceability.Domain.Service.SlaughterServices;
using Traceability.Domain.SlaughterDomain;

namespace Architecture.API.Application.TraceabilityCommandHandler.SlaughterCommandHandler
{
    /// <summary>
    /// 屠宰信息反填命令处理器
    /// </summary>
    public class SlaughterReverseCommandHandler : IRequestHandler<SlaughterReverseCommand, Slaughter>
    {
        /// <summary>
        /// 屠宰服务
        /// </summary>
        protected readonly ISlaughterService slaughterService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="slaughterService">屠宰服务</param>
        public SlaughterReverseCommandHandler(ISlaughterService slaughterService)
        {
            this.slaughterService = slaughterService;
        }

        /// <summary>
        /// 反填屠宰信息
        /// </summary>
        /// <param name="request">请求</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Slaughter> Handle(SlaughterReverseCommand request, CancellationToken cancellationToken)
        {
            return await slaughterService.GetSlaughterModel(request.slaughterId);
        }
    }
}
